package com.isoftstone.framework.config;

import com.isoftstone.framework.interceptor.RepeatSubmitInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import java.io.File;
import java.io.FileNotFoundException;

/**
 * @Description:
 * @Author: guoX
 * @Date: 2019/11/25
 */
@Configuration
public class WebApiConfig extends WebMvcConfigurationSupport {


    @Autowired
    RepeatSubmitInterceptor repeatSubmitInterceptor;


    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");

        registry.addResourceHandler("/profile/**").addResourceLocations("file:"+ToolConfig.getProfile()+"/");

    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**");

    }

}
